-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add is_section_start support to Phrase class (Issue #47) #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Resolves Issue #47 Add support for the is_section_start attribute to enable phrase-based section tracking, replacing the fragile index-based sectionStartsGrid system. This architectural improvement ensures section markers move with their phrases during insertions/deletions, eliminating section index drift bugs. ## Changes: ### Phrase Class (phrase.py): - Add 'is_section_start' to allowed parameters - Initialize is_section_start attribute (optional boolean: True/False/None) - Add type validation (must be boolean if provided) - Include is_section_start in serialization (to_json) ### Piece Class (piece.py): - Add migration logic to convert old sectionStartsGrid to phrase properties - When loading old data, automatically sets is_section_start on phrases - Maintains full backward compatibility with existing code ## Testing: - 9 comprehensive test cases covering: - Phrase initialization (True/False/None) - Type validation - Serialization round-trip - Migration from old sectionStartsGrid format - Multi-track pieces - All 365 existing tests continue to pass ## Benefits: - Section status is intrinsic to phrases, not external indices - Eliminates section drift when phrases are added/removed - Backward compatible with existing sectionStartsGrid data - Matches TypeScript implementation in main IDTAP project 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
📦 Test Package Built Successfully! This PR has been automatically built and uploaded to TestPyPI for testing. 🔗 TestPyPI Link: https://test.pypi.org/project/idtap/ To test this version: pip install --index-url https://test.pypi.org/simple/ idtap✅ All tests passed and package builds successfully. |
|
@claude review |
|
Claude finished @jon-myers's task —— View job Code Review Complete ✅Review Tasks:
Review SummaryThis PR successfully implements Code Quality Assessment✅ Excellent Code Quality
✅ Best Practices Followed
Bug Analysis✅ No Critical Issues Found
|
Summary
Implements support for the
is_section_startattribute in thePhraseclass, enabling phrase-based section tracking. This is a major architectural improvement that replaces the fragile index-basedsectionStartsGridsystem.Resolves #47
Background
The main IDTAP project migrated to phrase-based section tracking in commit 057f8f02 (Sept 2024), adding the
isSectionStartboolean property to phrases. The Python API was not updated, causingValueErrorwhen loading transcriptions containing this attribute.The Problem: Index Drift
Old System (
sectionStartsGrid)New System (
is_section_start)is_section_startpropertyImplementation Details
1. Phrase Class Updates (
phrase.py)Parameter Validation (line 165)
'is_section_start'to allowed constructor parametersType Validation (lines 269-272)
is_section_startmust be a boolean (if provided)True,False, orNone(not provided)Initialization (lines 87-88)
self.is_section_start = opts.get('is_section_start')Noneif not specifiedSerialization (line 581)
'isSectionStart': self.is_section_startinto_json()output2. Piece Class Migration Logic (
piece.py:180-188)Automatic migration from old
sectionStartsGridto phrase properties:This ensures:
sectionStartsGridautomatically converts to phrase propertiesis_section_starton phrases works nativelyTesting
New Test Coverage (9 tests)
Phrase Tests (6 tests in
phrase_test.py)✅ Initialization with
is_section_start=True✅ Initialization with
is_section_start=False✅ Default behavior (
is_section_start=None)✅ Type validation (non-boolean raises TypeError)
✅ Serialization includes
isSectionStart✅ Round-trip serialization preservation
Piece Migration Tests (3 tests in
piece_test.py)✅ Migration from
sectionStartsGridto phrase properties (single track)✅ Migration for multi-track pieces
✅ Preserves existing
is_section_startvalues when presentTest Results
is_section_starttests)Example Usage
New Data (with is_section_start)
Old Data Migration (automatic)
Benefits
sectionStartsGriddata migrates automaticallyBackward Compatibility
✅ Fully backward compatible
sectionStartsGridcontinues to worksectionStartsGridstill exists and is populated by migrationChecklist
sectionStartsGridformatRelated
🤖 Generated with Claude Code